package com.hsurosy.hsuchain.nft.order.infrastructure.config;

import com.hsurosy.hsuchain.nft.api.collection.service.CollectionFacadeService;
import com.hsurosy.hsuchain.nft.api.goods.service.GoodsFacadeService;
import com.hsurosy.hsuchain.nft.api.pay.service.PayFacadeService;
import com.hsurosy.hsuchain.nft.api.user.service.UserFacadeService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 订单服务相关的Dubbo服务配置类
 *
 * @Author Hsu琛君珩
 * @Date 2024-10-05 17:53
 * @Description
 * @Version: v1.0.0
 */
@Configuration
public class OrderDubboConfiguration {

    @DubboReference(version = "1.0.0")
    private CollectionFacadeService collectionFacadeService;

    @DubboReference(version = "1.0.0")
    private UserFacadeService userFacadeService;

    @DubboReference(version = "1.0.0")
    private PayFacadeService payFacadeService;

    @DubboReference(version = "1.0.0")
    private GoodsFacadeService goodsFacadeService;

    /**
     * 注入 CollectionFacadeService 实例
     * <p>
     * 如果系统中没有定义 CollectionFacadeService 的bean，则使用该方法提供的默认实例。
     *
     * @return CollectionFacadeService 实例
     */
    @Bean
    @ConditionalOnMissingBean(name = "collectionFacadeService")
    public CollectionFacadeService collectionFacadeService() {
        return this.collectionFacadeService;
    }

    /**
     * 注入 UserFacadeService 实例
     * <p>
     * 如果系统中没有定义 UserFacadeService 的bean，则使用该方法提供的默认实例。
     *
     * @return UserFacadeService 实例
     */
    @Bean
    @ConditionalOnMissingBean(name = "userFacadeService")
    public UserFacadeService userFacadeService() {
        return this.userFacadeService;
    }

    /**
     * 注入 PayFacadeService 实例
     * <p>
     * 如果系统中没有定义 PayFacadeService 的bean，则使用该方法提供的默认实例。
     *
     * @return PayFacadeService 实例
     */
    @Bean
    @ConditionalOnMissingBean(name = "payFacadeService")
    public PayFacadeService payFacadeService() {
        return this.payFacadeService;
    }

    /**
     * 注入 GoodsFacadeService 实例
     * <p>
     * 如果系统中没有定义 GoodsFacadeService 的bean，则使用该方法提供的默认实例。
     *
     * @return GoodsFacadeService 实例
     */
    @Bean
    @ConditionalOnMissingBean(name = "goodsFacadeService")
    public GoodsFacadeService goodsFacadeService() {
        return this.goodsFacadeService;
    }
}
